<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户代码片段</title>
</head>

<body>
    <div></div>
    <div class="box"></div>
    <pre class="pre"></pre>
    <script src="./js/单词.js"></script>
    <script>
        var box = document.querySelector(".box");
        var pre = document.querySelector("pre");
        // console.log(cat);
        var ptt = /[a-zA-Z_]+/gi;
        // var arr = /[a-zA-Z]+/gi.exec(cat);
        var arr = cat.match(ptt);
        // console.log(arr);
        box.onclick = function(e){
            e.stopPropagation();
        }
        var blackCat = ``;
        var check = [];
        [].forEach.call(arr, function(value){
            if(check.indexOf(value)==-1){
                check.push(value);
            }
        });
        [].forEach.call(check, function(item){
            blackCat+=
            `"call to .${item}": {
                "prefix": ".${item}",
                "body": [
                    ".${item}",
                ],
                "description": "call to .${item}"
            },\r\n`;
            blackCat+=
            `"call to ${item}": {
                "prefix": "${item}",
                "body": [
                    "${item}",
                ],
                "description": "call to ${item}"
            },\r\n`;
        });
        console.log(blackCat);
        pre.innerHTML = blackCat;
    </script>
</body>

</html>